package com.test.kotlin05


class Player5(
    _name:String,
    var age:Int = 20, //构造函数默认值
    var isNormal:Boolean //在主构造函数里定义属性
) {
    var name = _name
        get() = field.capitalize()
        set(value){
            field = value.trim()
        }


    constructor(name:String):this(name,age =10,isNormal =false)//次构造函数


    constructor(name:String,age: Int):this(name,age =10,isNormal =false){
        this.name = name.toUpperCase()
    }

    init{//初始化块
        require(age>0){
            "age must be positive"
        }

        require(name.isNotBlank()){
            "player must have a name "
        }
    }



}


fun main() {
    val player:Player5 = Player5("jack",isNormal =  false)
    println(player.age)

}